home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / comm2 / amislt14.lha / AmiSlate / SlateRexx / tictactoe.rexx < prev    next >
OS/2 REXX Batch file  |  1996-01-27  |  16KB  |  554 lines

  1. /* TicTacToe for AmiSlate v1.0! */
  2.  
  3. /* Constants for use with AmiSlate's ARexx interface */
  4. AMode.DOT      =  0 
  5. AMode.PEN      =  1 
  6. AMode.LINE     =  2 
  7. AMode.CIRCLE   =  3 
  8. AMode.SQUARE   =  4 
  9. AMode.POLY     =  5 
  10. AMode.FLOOD    =  6 
  11. AMode.CLEAR    =  7 
  12.  
  13. AMessage.TIMEOUT     = 1    /* No events occurred in specified time period */
  14. AMessage.MESSAGE     = 2    /* Message recieved from remote Amiga */
  15. AMessage.MOUSEDOWN   = 4    /* Left mouse button press in drawing area */
  16. AMessage.MOUSEUP     = 8    /* Left mouse button release in drawing area */
  17. AMessage.RESIZE      = 16    /* Window was resized--time to redraw screen? */ 
  18. AMessage.QUIT        = 32    /* AmiSlate is shutting down */
  19. AMessage.CONNECT     = 64    /* Connection established */
  20. AMessage.DISCONNECT  = 128    /* Connection broken */
  21. AMessage.TOOLSELECT  = 256    /* Tool Selected */
  22. AMessage.COLORSELECT = 512    /* Palette Color selected */
  23. AMessage.KEYPRESS    = 1024    /* Key pressed */
  24. AMessage.MOUSEMOVE   = 2048     /* Mouse was moved */
  25.  
  26. /* Get our host's name--always given as first argument when run from Amislate */
  27. parse arg CommandPort ActiveString
  28.  
  29. if (length(CommandPort) == 0) then do
  30.     say ""
  31.     say "Usage:  rx tictactoe.rexx <REXXPORTNAME>"
  32.     say "        (REXXPORTNAME is usually AMISLATE)"
  33.     say ""
  34.     say "Or run from the Rexx menu within AmiSlate."
  35.     say ""
  36.     exit 0
  37.     end
  38.  
  39. /* Send all commands to this host */
  40. address (CommandPort) 
  41.  
  42.  
  43. options results
  44.  
  45. /* Reserves pixels for a future toolbar -- currently, none */
  46. ToolBarHeight = 0
  47.  
  48. /* Check to see which tool is selected, whether we are connected */
  49. BFlood = 0
  50.  
  51. /* Parse command line argument to see if we've been activated by 
  52.    a remote request or a local user */
  53. check = upper(left(ActiveString,3))
  54. if (upper(left(ActiveString,3)) ~= 'RE') then 
  55.     do
  56.         BActive = 1
  57.     end
  58.     else
  59.     do    
  60.         BActive = 2
  61.     end
  62.  
  63. /* See if we're connected */
  64. GetRemoteStateAttrs stem rstateattrs.
  65.  
  66. if (rstateattrs.mode > -1) then 
  67.     do
  68.         BConnectMode = 1
  69.     end
  70.     else
  71.     do
  72.         BConnectMode = 0
  73.     end
  74.     
  75. /* Disable drawing */
  76. lock on
  77.  
  78. /* Initialize TicTacToe board */
  79. success = InitTTTArray()
  80.  
  81. /* Initiator (X) goes first */
  82. turn = 1
  83. moves = 0
  84.  
  85. /* If there are more than 4 colors on the screen, set some palette positions
  86.    to the ones we want to fill our marks with */
  87. GetWindowAttrs stem winattrs.
  88. SetPenColor 1 00 00 00
  89. SetPenColor 2 15 15 15
  90. if (winattrs.depth > 2) then do
  91.     SetPenColor 5 06 15 06        /* avoid setting pens 2&3 if possible */
  92.     SetPenColor 4 15 06 06    
  93. end
  94. else do
  95.     SetPenColor 3 06 15 06    
  96.     SetPenColor 2 15 06 06    
  97. end
  98.  
  99.  
  100.  
  101. /* Handshaking for two-computer game */
  102. if (BConnectMode = 1) then 
  103. do
  104.     if (BActive == 1) then 
  105.     do
  106.  
  107.         SetWindowTitle '"'||"Requesting game from remote user"||'"' 
  108.     RemoteRexxCommand '"'||"Would you like to play TicTacToe?"||'"' "slaterexx:TicTacToe.rexx"
  109.     
  110.         waitevent stem handshake. MESSAGE
  111.         if (handshake.message == 0) then 
  112.         do
  113.             SetWindowTitle '"'||"TicTacToe Game Refused"||'"'
  114.             exit
  115.         end
  116.     success = DrawTTTBoard()
  117.     end
  118.     else
  119.     do
  120.         /* Examine window to get dimensions */
  121.     GetWindowAttrs stem winattrs.
  122.        BoardWidth = winattrs.width  - 58
  123.        BoardHeight= winattrs.height - 53 - ToolBarHeight
  124.     end
  125. end
  126. else 
  127. do
  128.     success = DrawTTTBoard()
  129. end        
  130.  
  131. success = UpdateStatus()
  132. do while(1)    
  133.     waitevent stem event. RESIZE MOUSEUP MESSAGE TOOLSELECT DISCONNECT QUIT
  134.     if ((event.type == AMessage.TOOLSELECT)&(event.code1 = AMode.CLEAR)) then do
  135.         SetWindowTitle '"'||"Starting New Game"||'"'
  136.         success = InitTTTArray()
  137.         success = DrawTTTBoard()
  138.         
  139.         /* Tell partner that the board has been cleared */
  140.         if (BConnectMode == 1) then SendMessage 99
  141.         end
  142.         
  143.     if (event.type == AMessage.DISCONNECT) then BConnectMode = 0
  144.     if (event.type == AMessage.QUIT) then exit
  145.     if (event.type == AMessage.RESIZE) then do
  146.         if ((BActive == 1)|(BConnectMode == 0)) then do
  147.            success = DrawTTTBoard()
  148.         end
  149.         else do
  150.            /* Just examine window to get new dimensions */
  151.            GetWindowAttrs stem winattrs.
  152.            BoardWidth = winattrs.width  - 58
  153.            BoardHeight= winattrs.height - 53 - ToolBarHeight
  154.         end
  155.              success = UpdateStatus()
  156.     end
  157.         
  158.     if (event.type == AMessage.MESSAGE) then do
  159.         if (event.message == 99) then do
  160.                 success = InitTTTArray()
  161.                 success = UpdateStatus()
  162.             end
  163.             else do
  164.                 if (turn ~= BActive) then success = ParseMove(event.message)
  165.             end
  166.             end
  167.             
  168.     if ((moves < 9)&((event.type == AMessage.MOUSEUP)&((turn == BActive)|(BConnectMode == 0)))) then 
  169.     do
  170.         xx = 3     /* default */
  171.         if (event.x < (2*(BoardWidth / 3))) then xx = 2
  172.         if (event.x < (BoardWidth / 3)) then xx = 1
  173.         
  174.         yy = 3     /* default */
  175.         if (event.y < (2*(BoardHeight / 3))) then yy = 2
  176.         if (event.y < (BoardHeight / 3)) then yy = 1
  177.         
  178.         if (TTTBoard.xx.yy > 0) then do
  179.             SetWindowTitle '"'||"You can't move there!"||'"'
  180.             end
  181.         else do
  182.             success = DoMove(xx,yy)
  183.             end
  184.     end
  185. end
  186.  
  187. exit
  188.  
  189. /* --------------------------------------------------------------- */
  190. /* procedure DoMove                           */
  191. /* --------------------------------------------------------------- */
  192. DoMove: procedure expose TTTBoard. turn moves BConnectMode BActive BoardWidth BoardHeight ToolBarHeight
  193.     parse arg xx,yy 
  194.     
  195.     TTTBoard.xx.yy = turn 
  196.  
  197.     if ((BConnectMode == 0)|(turn == BActive)) then success = DrawMove(xx,yy)
  198.     if ((BConnectMode == 1)&(turn == BActive)) then do
  199.         message = xx||yy
  200.         SendMessage message
  201.         end    
  202.                 
  203.     if (turn == 1) then do
  204.         turn = 2
  205.         end
  206.         else do
  207.         turn = 1
  208.         end
  209.     moves=moves+1
  210.     success = CheckForWins()
  211.     if ((success > 0)|(moves>=9)) then do
  212.         moves = 9 /* disallow more movement */
  213.         if (success == 1) then SetWindowTitle '"'||"X's won!  Click CLR to play again" ||'"'
  214.         if (success == 2) then SetWindowTitle '"'||"O's won!  Click CLR to play again" ||'"'
  215.         if (success == 0) then SetWindowTitle '"'||"Cat's game!  Click CLR to play again" ||'"'
  216.         end
  217.         else do
  218.         success = UpdateStatus()
  219.         end
  220.     return 1
  221.     
  222.  
  223. /* --------------------------------------------------------------- */
  224. /* procedure CheckForWins                       */
  225. /* --------------------------------------------------------------- */
  226. CheckForWins: procedure expose TTTBoard. BoardWidth BoardHeight ToolBarHeight turn BActive BConnectMode
  227.  
  228.     i=1
  229.     do while (i<4)
  230.         if ((TTTBoard.i.1==1)&(TTTBoard.i.2==1)&(TTTBoard.i.3==1)) then do
  231.             if ((turn == BActive)|(BConnectMode == 0)) then do
  232.                 SetFColor 15 15 15 notbackground
  233.                 BHeight = BoardHeight - ToolBarHeight
  234.                 if (i==1) then barleft = trunc(BoardWidth*.13)
  235.                 if (i==2) then barleft = trunc(BoardWidth*.47)
  236.                 if (i==3) then barleft = trunc(BoardWidth*.82)
  237.                 square barleft ToolBarHeight+trunc(BHeight*.05) (barleft+trunc(BoardWidth*.05)) (ToolBarHeight+trunc(BHeight*.95)) fill
  238.                 SetFColor 0 0 0 notbackground
  239.                 square barleft ToolBarHeight+trunc(BHeight*.05) (barleft+trunc(BoardWidth*.05)) (ToolBarHeight+trunc(BHeight*.95))
  240.                 end
  241.             return 1
  242.             end
  243.             
  244.         if ((TTTBoard.i.1==2)&(TTTBoard.i.2==2)&(TTTBoard.i.3==2)) then do
  245.             if ((turn == BActive)|(BConnectMode == 0)) then do
  246.                 SetFColor 15 15 15 notbackground
  247.                 BHeight = BoardHeight - ToolBarHeight
  248.                 if (i==1) then barleft = trunc(BoardWidth*.13)
  249.                 if (i==2) then barleft = trunc(BoardWidth*.47)
  250.                 if (i==3) then barleft = trunc(BoardWidth*.82)
  251.                 square barleft ToolBarHeight+trunc(BHeight*.05) (barleft+trunc(BoardWidth*.05)) (ToolBarHeight+trunc(BHeight*.95)) fill
  252.                 SetFColor 0 0 0 notbackground
  253.                 square barleft ToolBarHeight+trunc(BHeight*.05) (barleft+trunc(BoardWidth*.05)) (ToolBarHeight+trunc(BHeight*.95))
  254.                 end
  255.             return 2
  256.             end
  257.             
  258.         i = i + 1
  259.         end
  260.     i=1
  261.     do while (i<4)
  262.         if ((TTTBoard.1.i==1)&(TTTBoard.2.i==1)&(TTTBoard.3.i==1)) then do
  263.             if ((turn == BActive)|(BConnectMode == 0)) then do
  264.                 SetFColor 15 15 15 notbackground
  265.                 BHeight = BoardHeight - ToolBarHeight
  266.                 if (i==1) then bartop = trunc((BHeight*.13)+ToolBarHeight)
  267.                 if (i==2) then bartop = trunc((BHeight*.47)+ToolBarHeight)
  268.                 if (i==3) then bartop = trunc((BHeight*.82)+ToolBarHeight)
  269.                 square trunc(BoardWidth*.05) bartop trunc(BoardWidth*.95) (bartop+trunc(BHeight/20)) fill
  270.                 SetFColor 0 0 0 notbackground
  271.                 square trunc(BoardWidth*.05) bartop trunc(BoardWidth*.95) (bartop+trunc(BHeight/20))
  272.                 end
  273.             return 1
  274.             end
  275.  
  276.         if ((TTTBoard.1.i==2)&(TTTBoard.2.i==2)&(TTTBoard.3.i==2)) then do
  277.             if ((turn == BActive)|(BConnectMode == 0)) then do
  278.                 SetFColor 15 15 15 notbackground
  279.                 BHeight = BoardHeight - ToolBarHeight
  280.                 if (i==1) then bartop = trunc((BHeight*.13)+ToolBarHeight)
  281.                 if (i==2) then bartop = trunc((BHeight*.47)+ToolBarHeight)
  282.                 if (i==3) then bartop = trunc((BHeight*.82)+ToolBarHeight)
  283.                 square trunc(BoardWidth*.05) bartop trunc(BoardWidth*.95) (bartop+trunc(BHeight/20)) fill
  284.                 SetFColor 0 0 0 notbackground
  285.                 square trunc(BoardWidth*.05) bartop trunc(BoardWidth*.95) (bartop+trunc(BHeight/20))
  286.                 end
  287.             return 2
  288.             end
  289.             
  290.         i = i + 1
  291.         end
  292.  
  293.     if ((TTTBoard.1.1==1)&(TTTBoard.2.2==1)&(TTTBoard.3.3==1)) then do
  294.         n = DrawDiagWinLine(1)
  295.         return 1
  296.         end
  297.         
  298.     if ((TTTBoard.1.1==2)&(TTTBoard.2.2==2)&(TTTBoard.3.3==2)) then do
  299.         n = DrawDiagWinLine(1)
  300.         return 2
  301.         end
  302.         
  303.     if ((TTTBoard.3.1==1)&(TTTBoard.2.2==1)&(TTTBoard.1.3==1)) then do
  304.         n = DrawDiagWinLine(0)
  305.         return 1
  306.         end
  307.         
  308.     if ((TTTBoard.3.1==2)&(TTTBoard.2.2==2)&(TTTBoard.1.3==2)) then do
  309.         n = DrawDiagWinLine(0)
  310.         return 2
  311.         end
  312.     
  313.     return 0
  314.  
  315.  
  316. /* --------------------------------------------------------------- */
  317. /* procedure DrawDiagWinLine                       */
  318. /*                                   */
  319. /* Draws a diagonal win line.  If TLtoBR is 1, draws it from the   */
  320. /* top left to the bottom right.  Otherwise, draws it from the     */
  321. /* bottom left to the top right.                     */
  322. /*                                   */
  323. /* --------------------------------------------------------------- */
  324. DrawDiagWinLine: procedure expose BActive turn BoardWidth BoardHeight ToolBarHeight TTTBoard.
  325.     parse arg TLtoBR
  326.  
  327.     cur = 0
  328.     maxcur = trunc(BoardWidth * .025)
  329.     BHeight = BoardHeight - ToolBarHeight
  330.     startX = trunc(BoardWidth * 0.05)
  331.     
  332.     if (TLtoBR == 1) then do
  333.         startY = trunc(BHeight * .1) + ToolBarHeight
  334.         dY = -1
  335.         end
  336.     else do    
  337.         startY = trunc(BHeight * .05) + trunc((BHeight*.83)+ToolBarHeight)
  338.         dY = 1
  339.         end
  340.     
  341.     setfcolor 15 15 15 notbackground
  342.     endX = startX + trunc(BoardWidth * .83)
  343.     endY = startY + trunc((-dY)*trunc(BHeight * .83))
  344.  
  345.     osX = startX
  346.     osY = startY
  347.     oeX = endX
  348.     oeY = endY
  349.     
  350.     do while (cur < maxcur)
  351.         line startX startY endX endY
  352.         line (startX+1) startY (endX+1) endY
  353.  
  354.         startX = startX + 1
  355.         startY = startY + dY
  356.         endX = endX + 1
  357.         endY = endY + dY
  358.         cur = cur + 1
  359.         end
  360.         
  361.     setfcolor 0 0 0 notbackground 
  362.     line oeX+1 oeY endx+1 endy
  363.     line osX osY startX startY
  364.  
  365.     line startx starty endX endY
  366.     line osX osY oeX oeY
  367.     
  368.     return 1
  369.  
  370.     
  371.     
  372. /* --------------------------------------------------------------- */
  373. /* procedure DrawMove                           */
  374. /* --------------------------------------------------------------- */
  375. DrawMove: procedure expose BActive turn BoardWidth BoardHeight ToolBarHeight TTTBoard.
  376.     parse arg xx,yy
  377.  
  378.     if (TTTBoard.xx.yy == 0) then return 1
  379.     
  380.     BHeight = BoardHeight - ToolBarHeight
  381.     
  382.     if (yy == 1) then do
  383.         ytop = ToolBarHeight
  384.         ybot = trunc(BHeight*.3)+ToolBarHeight
  385.         end
  386.         
  387.     if (yy == 2) then do
  388.         ytop = trunc(BHeight*.36)+ToolBarHeight
  389.         ybot = trunc(BHeight*.63)+ToolBarHeight
  390.         end
  391.         
  392.     if (yy == 3) then do
  393.         ytop = trunc(BHeight*.69)+ToolBarHeight 
  394.         ybot = trunc(BHeight*.99)+ToolBarHeight
  395.         end
  396.         
  397.     if (xx == 1) then do
  398.         xleft = 1
  399.         xright = trunc(BoardWidth*.3)
  400.         end
  401.         
  402.     if (xx == 2) then do
  403.         xleft = trunc(BoardWidth*.36)
  404.         xright = trunc(BoardWidth*.63)
  405.         end
  406.         
  407.     if (xx == 3) then do
  408.         xleft = trunc(BoardWidth*.69)
  409.         xright = trunc(BoardWidth*.99)
  410.         end
  411.         
  412. /*    square xleft ytop xright ybot fill */
  413.     if (TTTBoard.xx.yy == 1) then do
  414.         penreset
  415.         height = ybot - ytop
  416.         width  = xright - xleft
  417.         th = 3
  418.  
  419.         SetFColor 0 0 0 notbackground
  420.         pen trunc(xleft+(width/th))     ytop
  421.         pen trunc(xleft+(width/2))     trunc(ytop+(height/th))
  422.         pen trunc(xright-(width/th))     ytop
  423.         pen xright             trunc(ytop+(height/th))
  424.         pen trunc(xright-(width/th))     trunc(ytop+(height/2))
  425.         pen xright             trunc(ybot-(height/th))
  426.         pen trunc(xright-(width/th))     ybot
  427.         pen trunc(xright-(width/2))     trunc(ybot-(height/th))
  428.         pen trunc(xleft+(width/th))     ybot
  429.         pen xleft             trunc(ybot-(height/th))
  430.         pen trunc(xleft+(width/th))     trunc(ybot-(height/2))
  431.         pen xleft             trunc(ytop+(height/th))
  432.         pen trunc(xleft+(width/th))    ytop
  433.  
  434.         SetFColor 15 6 6 notbackground
  435.         
  436.         flood trunc((xleft + xright)/2) trunc((ytop + ybot)/2)
  437.         end
  438.     else do
  439.         SetFColor 0 0 0 notbackground
  440.         circle trunc((xleft+xright)/2) trunc((ytop+ybot)/2) trunc((xright - xleft)/2) trunc((ybot - ytop)/2)
  441.         circle trunc((xleft+xright)/2) trunc((ytop+ybot)/2) trunc((xright - xleft)/3) trunc((ybot - ytop)/3)
  442.  
  443.         SetFColor 6 15 6 notbackground
  444.         flood trunc(((xleft+xright)/2)+((xleft-xright)/2.5)) trunc((ytop+ybot)/2)
  445.         end
  446.     return 1
  447.     
  448.         
  449.  
  450.  
  451. /* --------------------------------------------------------------- */
  452. /* procedure UpdateStatus                       */
  453. /* --------------------------------------------------------------- */
  454. UpdateStatus: procedure expose BActive turn BConnectMode moves
  455.  
  456.     if (moves > 8) then do
  457.         SetWindowTitle '"'||"Game Over, click CLR to play again"||'"'
  458.         return 1
  459.         end
  460.         
  461.     if ((BActive == turn)|(BConnectMode == 0)) then do
  462.         if (turn == 1) then SetWindowTitle '"'||"It's Your Turn, Player X"||'"'
  463.         if (turn == 2) then SetWindowTitle '"'||"It's Your Turn, Player O"||'"'
  464.     end
  465.     else
  466.     do
  467.         if (turn == 1) then SetWindowTitle '"'||"It's Their Turn (Player X)"||'"'
  468.         if (turn == 2) then SetWindowTitle '"'||"It's Their Turn (Player O)"||'"'
  469.     end
  470.     
  471.     return 1
  472.  
  473. /* --------------------------------------------------------------- */
  474. /* procedure InitTTTArray                       */
  475. /* --------------------------------------------------------------- */
  476. InitTTTArray: procedure expose TTTBoard. moves turn
  477.     TTTBoard.1.1 = 0
  478.     TTTBoard.1.2 = 0
  479.     TTTBoard.1.3 = 0
  480.     TTTBoard.2.1 = 0
  481.     TTTBoard.2.2 = 0
  482.     TTTBoard.2.3 = 0
  483.     TTTBoard.3.1 = 0
  484.     TTTBoard.3.2 = 0
  485.     TTTBoard.3.3 = 0
  486.     turn  = 1
  487.     moves = 0
  488.     return 1
  489.     
  490.  
  491. /* --------------------------------------------------------------- */
  492. /* procedure DrawTTTBoard                       */
  493. /* --------------------------------------------------------------- */
  494. DrawTTTBoard: procedure expose TTTBoard. BoardWidth BoardHeight ToolBarHeight turn BActive moves BConnectMode
  495.  
  496.    /* Say what we're doing */
  497.    SetWindowTitle '"'||"Drawing TicTacToe board, Please Wait"||'"'
  498.    SetRemoteWindowTitle '"'||"Drawing TicTacToe board, Please Wait"||'"'
  499.    
  500.    /* Examine window to get dimensions */
  501.    GetWindowAttrs stem winattrs.
  502.    BoardWidth = winattrs.width  - 58
  503.    BoardHeight= winattrs.height - 53
  504.  
  505.    /* Clear Screen */
  506.    clear
  507.  
  508.    /* Draw Board */
  509.    SetFColor 0 0 0 notbackground
  510.  
  511.    /* Height of Board */
  512.    BHeight = BoardHeight - ToolBarHeight   
  513.    
  514.    square (trunc(BoardWidth*.31)) ToolBarHeight (trunc(BoardWidth*.35)) BoardHeight fill
  515.    square (trunc(BoardWidth*.64)) ToolBarHeight (trunc(BoardWidth*.68)) BoardHeight fill
  516.    square 0 (trunc(BHeight*.31)+ToolBarHeight) BoardWidth (trunc(BHeight*.35)+ToolBarHeight) fill
  517.    square 0 (trunc(BHeight*.64)+ToolBarHeight) BoardWidth (trunc(BHeight*.68)+ToolBarHeight) fill
  518.    
  519.    success=DrawMove(1,1)
  520.    success=DrawMove(2,1)
  521.    success=DrawMove(3,1)
  522.    success=DrawMove(1,2)
  523.    success=DrawMove(2,2)
  524.    success=DrawMove(3,2)
  525.    success=DrawMove(1,3)
  526.    success=DrawMove(2,3)
  527.    success=DrawMove(3,3)
  528.  
  529.    success=CheckForWins()
  530.    if (success == 0) then success=UpdateStatus()
  531.    return 1
  532.    
  533.  
  534. /* --------------------------------------------------------------- */
  535. /* procedure ParseMove                           */
  536. /* --------------------------------------------------------------- */
  537. ParseMove: procedure expose TTTBoard. BoardWidth BoardHeight ToolBarHeight turn moves BActive BConnectMode
  538.     parse arg message
  539.  
  540.     xx=left(message,1)
  541.     yy=right(message,1)
  542.  
  543.     if ((xx>3)||(xx<0)|(yy>3)||(yy<0)) then do
  544.         SetWindowTitle '"'||"TicTacToe Transmission Trouble :("||'"'
  545.         return 0
  546.         end
  547.         
  548.     if (TTTBoard.xx.yy > 0) then do
  549.         EasyRequest '"'||"TicTacToe Message"||'"' '"'||"Your opponent is cheating (" || xx yy TTTBoard.xx.yy || ") !"||'"' '"'||"What a maroon"||'"'
  550.     end
  551.     else do
  552.         success=DoMove(xx,yy) 
  553.     end
  554.     return 1